import pandas
import os
import getpath
import bjItems
def merge(file_name):
    file=os.path.join(getpath.getpath(),"spec",file_name)
    # file=os.path.join(getpath.getpath(),"spec","不锈钢Ni3-6，8-12.xlsx")
    # db.import_std_file2(file)
    d= pandas.read_excel(file,sheet_name=None)
    d2=pandas.concat(d)
    d2.to_excel(file_name)
def t2():
    # 添加新列
    df['Salary'] = [50000, 60000, 70000]

    # 删除列
    df.drop('City', axis=1, inplace=True)

    # 排序
    df.sort_values(by='Age', ascending=False, inplace=True)

    # 重命名列
    df.rename(columns={'Name': 'Full Name'}, inplace=True)   
def mergeAll():
    for one in["不锈钢Ni3-6，8-12.xlsx","low steel.xlsx","直读光谱控样库.xlsx","控样.xlsx"]:
        merge(one)
def mymerge(d1,d2):
    # for one in d1.columns:
    #     print(one,dir(one))
    # return
    # d1columns=list(map(lambda x:str(x),d1.columns))
    # d2columns=list(map(lambda x:str(x),d2.columns))
    # print(d1columns)
    # (left,right)=bjItems.bjitems(d1columns,d2columns)
    # print(left,right)
    # for one in right:
    #     d1[one]=None
    # for one in left:
    #     d2[one]=None
    return pandas.concat([d1,d2])
def t3():
    d1=pandas.DataFrame()
    d1["id"]=""
    d1["C"]=0
    d1["S"]=0
    d1["Si"]=0
    d1.loc[len(d1.index)]=["1",0,1,2]
    d2=pandas.DataFrame()
    d2["id"]=""
    d2["Mn"]=0
    d2["P"]=0
    d2["C"]=0
    d2.loc[len(d2.index)]=["1",3,4,5]
    d3=mymerge(d1,d2)#pandas.concat([d1,d2],axis=1)
    print(d3)
    # print(dir(d))
# t3()
mergeAll()